from sys import getfilesystemencoding
from types import StringType, UnicodeType

sysencoding = getfilesystemencoding()
version = "LH-ABC"

# To convert system errors to a Unicode string
def exceptionArgsToString(exception):
    exceptargs = u'('
    if exception.args:
        for a in exception.args:
            if type(a) == UnicodeType:
                exceptargs += u"'" + a + u"'"
            elif type(a) == StringType:
                exceptargs += u"'" + a.decode(sysencoding) + u"'"
            else:
                exceptargs += str(a)
            exceptargs += u', '
        exceptargs = exceptargs[:-2]
    return exceptargs + u')'

def setversion(ver):
    global version
    try:
        ver.encode("utf-8")
    except:
        pass
    version = ver
    
def getversion():
    global version
    return version
